// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: {
<<<<<<< .mine
      id:1,
      name:'zhangsan'

=======
        nickname:"浅羽曦",
        address:"河南省郑州市",
        id:2
>>>>>>> .theirs
    },
<<<<<<< .mine
    // baseUrl:'http://testserver.cpolar.top/api/',
    baseUrl:'http://localhost:8080/',

=======
    // baseUrl:'http://localhost:10013',
    baseUrl:'http://testserver.cpolar.top/api',
    // baseUrl:'https://wwyy.wzhxlx.com/wwyy/',
>>>>>>> .theirs
    token:'testToken'
  },
    requess: function (url, method, data) {
      const that = this;
      const defaultHeaders = {
        'content-type': 'application/json'
      };
      if (that.globalData.token) {
        defaultHeaders['Authorization'] = `Bearer ${that.globalData.token}`;
      }
      return new Promise((resolve, reject) => {
        console.log("idididi")
        console.log(data)
        wx.request({
          url: that.globalData.baseUrl + url,
          method: method,
          data: data,
          header: defaultHeaders,
          success: (res) => {
            console.log("99:");
            console.log(res);
            resolve(res);
          },
          fail: (err) => {
            console.log("error")
            console.log(err)
            reject(err);
          }
        });
      });
    },
    loginFilter:function(){
      if(this.globalData.token==''){
        wx.switchTab({
          url: '/pages/mine/mine',
          fail: () => {
            wx.showToast({
              title: '跳转失败，请重试',
              icon: 'none'
            });
          }
        })
      }
    },
})
